package com.homework.first.impl;

import com.homework.first.IArithmetic;

/**
 * @Author WaveHi
 * @Date 24/8/2021 下午 6:50
 * @Version 1.0
 * @Contact HJBWaveHi@163.com
 * @Description IArithmetic的实现类
 */
public class IArithmeticImpl implements IArithmetic {
    @Override
    public int addMethod(int num1, int num2) {

        return num1 + num2;

    }

    @Override
    public int subMethod(int num1, int num2) {

        return num1 - num2;

    }

    @Override
    public int mulMethod(int num1, int num2) {

        return num1 * num2;

    }

    @Override
    public int divMethod(int num1, int num2) {

        //异常情况处理
        if(num2 == 0) {

            throw new ArithmeticException("Divisor is zero!");

        }

        return num1 / num2;

    }
}

//小结：实现类的类名应以Impl为结尾。
